package config;

import example.Parrot;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

//使用@Configuration注解将其定义为Spring配置类，用于配置Spring上下文
@Configuration
public class ProjectConfig {
	// 通过@Bean注解，指示Spring在上下文初始化时调用这个方法
	// 并将方法的返回值添加到Spring上下文中

	@Bean
	@Primary
	Parrot parrot1() {
		Parrot p = new Parrot();
		p.setName("Koko");
		return p;
	}

	@Bean(name = "abc")
	Parrot parrot2() {
		Parrot p = new Parrot();
		p.setName("Miki");
		return p;
	}

	@Bean
	String hello() {
		return "Hello";
	}

	@Bean
	Integer ten() {
		return 10;
	}
}
